import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

//导入axios
import axios from './Utils/request'
Vue.prototype.$http=axios

//配置element
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

//配置echarts
import *as echarts from 'echarts'
Vue.prototype.$echarts=echarts

//全局守卫
router.beforeEach((to,from,next)=>{
  if(to.path=='/login'){
    if(store.state.token!=''){
      next('/home')
    }
  }else{
    if(store.state.token==''){
      next('/login')
    }
  }
  store.commit('addbread',to.meta.bread)
  next()
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
